import { baseRequestClient, requestClient } from '#/api/request';
// import { AuthApi } from '#/api/core';

export namespace ContractApi {
  /** 登录接口参数 */
  export interface ContractSo {
    keyword: string;
    contractStartTime: string;
    contractEndTime: string;
    uploadStartTime: string;
    uploadEndTime: string;
    clienteleId: string;
  }

  /** 登录接口返回值 */
  export interface ContractBo {
    contractName: string;
    contractDate: string;
    userId: string;
    files: ContractFileDto[];
  }

  export interface ContractFileDto {
    id: string;
    fileName: string;
    fileUrl: string;
    fileType: string;
    fileSize: string;
  }

  export interface ContractPageVo {
    id: string;
    contractName: string;
    contractDate: string;
    ownUserName: string;
    clienteleName: string;
    createTime: string;
  }

  export interface PageRequest {
    current: string;
    size: string;
    query: any;
  }
}

/**
 * 合同分页列表
 */
export async function pageContractApi(
  data: ContractApi.PageRequest<ContractApi.ContractSo>,
) {
  return requestClient.post<ContractApi.ContractPageVo>('/contract/page', data);
}

export async function uploadContractApi(
  data: ContractApi.PageRequest<ContractApi.ContractBo>,
) {
  return requestClient.post('/contract/upload', data);
}

export async function listFile(data) {
  return requestClient.get<ContractApi.ContractFileDto>('/contract/listFile', {
    params: {
      id: data,
    },
  });
}
